Auth();
var type = globalFun.GetQueryString('type');
if(type==3){
	$('.blur1').html('优秀志愿者')
	$('#vl_type').html('优秀志愿者')
}else if(type==4){
	$('.blur1').html('优秀志愿团队')
	$('#vl_type').html('优秀志愿团队')
}
hdList(1,true)
function hdList(page,init) {
	var hdObj = {
		type:type,
		pageNum: page,
		pageSize: 15,
	}
	$.ajax({
		type: "post",
		url: apicom + '/consultation/welcomeConsultation',
		async: true,
		data: hdObj,
		success: function(res) {
			if(typeof res == 'string') {
				res = JSON.parse(res);
			}
//			console.log(res)
			if(res.code == 200) {
				console.log(res)
				var dataScourse = res.data;
				if(dataScourse.length == 0) {
					$("#page").hide();
//					$('#vl_active_mian').html("<div class='center_kong'><img src='../img/f_2.png'/><p>活动为空！</p></div>");
					return false;
				}
				data(dataScourse);
				$("#page").show();
				all_num = res.pages;
				/* 分页 */
				if(init == true){
					$("#page").createPage({
						pageNum: all_num, //总页码
						current: 1, //当前页
						shownum: 7, //每页显示个数
						showPageNum: false, //显示总页数
						showToPage: false, //显示跳转页码
						backfun: function(e) {
							hdList(e.current, false);
						}
					});
				}
			} else {
				tips('暂无咨询')
			}
		},
		error: function(err) {
			console.log(err)
		}
	})
}
function data(content){
	var ss = '';
	for(var i = 0; i < content.length; i++){
		ss+='<p data-id="'+content[i].id+'" class="info_xq"><span class="dian">·</span><span class="hot_detail">'+content[i].title+'</span><span class="hot_time">'+content[i].createTime+'</span></p>'
	};
	$('.mian_xq').html(ss);
}
//热点资讯
$.ajax({
	type: "post",
	url: apicom + "/consultation/welcomeConsultation",
	data:{type:1},
	async: true,
	success: function(res) {
		console.log(res.data)
		var hot = res.data;
		if(hot.length>8){
			hot.length = 8;
		}
		var ss = ''
		for(var i = 0; i < hot.length; i++){
			ss+='<p data-id="'+hot[i].id+'" class="hot_p"><span class="dian">·</span><span class="hot_detail">'+hot[i].title+'</span></p>'
		};
		$('.r_main').html(ss);	
	},
	error: function(err) {

	}
});
//政策文件
$.ajax({
	type: "post",
	url: apicom + "/consultation/welcomeConsultation",
	data:{type:2},
	async: true,
	success: function(res) {
		console.log(res.data)
		var zhengce = res.data;
		var ss = ''
		if(zhengce.length>8){
			zhengce.length = 8;
		}
		for(var i = 0; i < zhengce.length; i++){
			ss+='<p data-id="'+zhengce[i].id+'" class="hot_p"><span class="dian">·</span><span class="hot_detail">'+zhengce[i].title+'</span></p>'
		};
		$('.z_main').html(ss);	
	},
	error: function(err) {

	}
});
//点击跳转资讯详情页
$('.mian_xq').on('click','.info_xq',function(){
	var zxId = $(this).attr('data-id');
	window.location.href = 'msg_detail.html?zxId='+zxId;
})
$(document).on('click','.hot_p',function(){
	var zxId = $(this).attr('data-id');
	window.location.href = 'msg_detail.html?zxId='+zxId;
})